<template>
  <div class="like-page">
    <van-nav-bar fixed
  title="我的喜欢" ></van-nav-bar>

  <van-list
  v-model="loading"
  :finished="finished"
  finished-text="没有更多了"
  @load="onLoad"
>
<article-item v-for="item in rows" :key="item.id" :item="item"></article-item>

</van-list>
  </div>
</template>

<script>
import { getArticlesLike } from '@/api/article'
export default {
  name: 'like-page',
  data () {
    return {
      rows: [],
      current: 1,
      loading: false,
      finished: false,
      sorter: 'weight_desc'
    }
  },
  methods: {
    async onLoad () {
      const res = await getArticlesLike({
        optType: 1,
        page: this.current,
        pageSize: 10

      })
      // console.log(res)
      this.rows.push(...res.data.data.rows)
      this.loading = false
      // 防止过度操作导致的其他bug 滑到最底部自动显示没有更多了
      if (this.current >= res.data.data.pageTotal) {
        // 加载完毕了
        this.finished = true
      }
      this.current++
    }
  }
}
</script>

<style lang="less" scoped>
.like-page {
  margin-bottom: 50px;
  margin-top: 44px;
}
</style>
